home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
Issue38
/
Clinic
/
RestartForm.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-07-07
|
1KB
|
51 lines
unit RestartForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
public
procedure WMEndSession(var Msg: TWMEndSession);
message wm_EndSession;
end;
var
Form1: TForm1;
implementation
uses
Registry;
{$R *.DFM}
procedure TForm1.WMEndSession(var Msg: TWMEndSession);
const
Restart = 'Software\Microsoft\Windows\CurrentVersion\RunOnce';
begin
if Msg.EndSession then
begin
with TRegistry.Create do
try
//If you want to run your app before any user
//logs in then uncomment the next line of code
//RootKey := HKEY_LOCAL_MACHINE;
if OpenKey(Restart, True) then
//Write a value with an arbitrary name,
//But the full path to your exe as a value
WriteString(Application.Title, Application.ExeName)
finally
Free //Destructor calls CloseKey for me
end;
Msg.Result := 0
end;
inherited
end;
end.